package com.javaeedev.junit;

import com.opensymphony.xwork.Action;

/**
 * Register a new user.
 */
public class RegisterAction implements Action {

    private Service service = new Service();

    private String username;
    private String password;
    private String email;

    public void setUsername(String username) {
        this.username = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String execute() {
        User user = new User();
        user.setUsername(username);
        user.setPassword(password);
        user.setEmail(email);
        try {
            service.createUser(user);
            return SUCCESS;
        }
        catch(Exception e) {
            return ERROR;
        }
    }

}
